home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 296_01.zip / FLEX.SKE < prev    next >
Text File  |  1993-04-01  |  7KB  |  337 lines

  1. /* A lexical scanner generated by flex */
  2.  
  3. #include "flexsdef.h"
  4.  
  5. %% section 1 code and data tables for DFA go here
  6.  
  7. /* these declarations have to come after the section 1 code or lint gets
  8.  * confused about whether the variables are used
  9.  */
  10. FILE *yyin = stdin, *yyout = stdout;
  11.  
  12. /* these variables are all declared out here so that section 3 code can
  13.  * manipulate them
  14.  */
  15. static int yy_start, yy_b_buf_p, yy_c_buf_p, yy_e_buf_p;
  16. static int yy_saw_eof, yy_init = 1;
  17.  
  18. /* yy_ch_buf has to be 1 character longer than YY_BUF_SIZE, since when
  19.  * setting up yytext we can try to put a '\0' just past the end of the
  20.  * matched text
  21.  */
  22. static char yy_ch_buf[YY_BUF_SIZE + 1];
  23. static int yy_st_buf[YY_BUF_SIZE];
  24. static char yy_hold_char;
  25. char *yytext;
  26. static int yyleng;
  27.  
  28. YY_DECL
  29.     {
  30.     int yy_n_chars, yy_lp, yy_iii, yy_buf_pos, yy_act;
  31.  
  32. %% user's declarations go here
  33.  
  34.     if ( yy_init )
  35.     {
  36.     YY_INIT;
  37.     yy_start = 1;
  38.     yy_init = 0;
  39.     }
  40.  
  41.     goto get_next_token;
  42.  
  43. do_action:
  44.     for ( ; ; )
  45.     {
  46.     YY_DO_BEFORE_ACTION
  47.  
  48. #ifdef FLEX_DEBUG
  49.     fprintf( stderr, "--accepting rule #%d\n", yy_act );
  50. #endif
  51.     switch ( yy_act )
  52.         {
  53. %% actions go here
  54.  
  55. case YY_NEW_FILE:
  56. break; /* begin reading from new file */
  57.  
  58. case YY_DO_DEFAULT:
  59. YY_DEFAULT_ACTION;
  60. break;
  61.  
  62. case YY_END_TOK:
  63. return ( YY_END_TOK );
  64.  
  65. default:
  66. YY_FATAL_ERROR( "fatal flex scanner internal error" );
  67.         }
  68.  
  69. get_next_token:
  70.     {
  71.     register int yy_curst;
  72.     register char yy_sym;
  73.  
  74.     YY_DO_BEFORE_SCAN
  75.  
  76.     /* set up to begin running DFA */
  77.  
  78.     yy_curst = yy_start;
  79.  
  80.     if ( yy_ch_buf[yy_c_buf_p] == '\n' )
  81.         ++yy_curst;
  82.  
  83.     /* yy_b_buf_p points to the position in yy_ch_buf
  84.      * of the start of the current run.
  85.      */
  86.  
  87.     yy_b_buf_p = yy_c_buf_p + 1;
  88.  
  89.     do /* until the machine jams */
  90.         {
  91.         if ( yy_c_buf_p == yy_e_buf_p )
  92.         { /* need more input */
  93.         if ( yy_e_buf_p >= YY_BUF_LIM )
  94.             { /* not enough room to do another read */
  95.             /* see if we can make some room for more chars */
  96.  
  97.             yy_n_chars = yy_e_buf_p - yy_b_buf_p;
  98.  
  99.             if ( yy_n_chars >= 0 )
  100.             /* shift down buffer to make room */
  101.             for ( yy_iii = 0; yy_iii <= yy_n_chars; ++yy_iii )
  102.                 {
  103.                 yy_buf_pos = yy_b_buf_p + yy_iii;
  104.                 yy_ch_buf[yy_iii] = yy_ch_buf[yy_buf_pos];
  105.                 yy_st_buf[yy_iii] = yy_st_buf[yy_buf_pos];
  106.                 }
  107.  
  108.             yy_b_buf_p = 0;
  109.             yy_e_buf_p = yy_n_chars;
  110.  
  111.             if ( yy_e_buf_p >= YY_BUF_LIM )
  112.             YY_FATAL_ERROR( "flex input buffer overflowed" );
  113.  
  114.             yy_c_buf_p = yy_e_buf_p;
  115.             }
  116.  
  117.         else if ( yy_saw_eof )
  118.             {
  119. saweof:            if ( yy_b_buf_p > yy_e_buf_p )
  120.             {
  121.             if ( yywrap() )
  122.                 {
  123.                 yy_act = YY_END_TOK;
  124.                 goto do_action;
  125.                 }
  126.             
  127.             else
  128.                 {
  129.                 YY_INIT;
  130.                 yy_act = YY_NEW_FILE;
  131.                 goto do_action;
  132.                 }
  133.             }
  134.  
  135.             else /* do a jam to eat up more input */
  136.             {
  137. #ifndef FLEX_INTERACTIVE_SCANNER
  138.             /* we're going to decrement yy_c_buf_p upon doing
  139.              * the jam.  In this case, that's wrong, since
  140.              * it points to the last non-jam character.  So
  141.              * we increment it now to counter the decrement.
  142.              */
  143.             ++yy_c_buf_p;
  144. #endif
  145.             break;
  146.             }
  147.             }
  148.  
  149.         YY_INPUT( (yy_ch_buf + yy_c_buf_p + 1), yy_n_chars,
  150.               YY_MAX_LINE );
  151.  
  152.         if ( yy_n_chars == YY_NULL )
  153.             {
  154.             if ( yy_saw_eof )
  155.     YY_FATAL_ERROR( "flex scanner saw EOF twice - shouldn't happen" );
  156.             yy_saw_eof = 1;
  157.             goto saweof;
  158.             }
  159.  
  160.         yy_e_buf_p += yy_n_chars;
  161.         }
  162.  
  163.         ++yy_c_buf_p;
  164.  
  165. #ifdef FLEX_USE_ECS
  166.         yy_sym = e[yy_ch_buf[yy_c_buf_p]];
  167. #else
  168.         yy_sym = yy_ch_buf[yy_c_buf_p];
  169. #endif
  170.  
  171. #ifdef FLEX_FULL_TABLE
  172.         yy_curst = n[yy_curst][yy_sym];
  173.  
  174. #else /* get next state from compressed table */
  175.  
  176.         while ( c[b[yy_curst] + yy_sym] != yy_curst )
  177.         {
  178.         yy_curst = d[yy_curst];
  179.  
  180. #ifdef FLEX_USE_MECS
  181.         /* we've arrange it so that templates are never chained
  182.          * to one another.  This means we can afford make a
  183.          * very simple test to see if we need to convert to
  184.          * yy_sym's meta-equivalence class without worrying
  185.          * about erroneously looking up the meta-equivalence
  186.          * class twice
  187.          */
  188.  
  189.         if ( yy_curst >= YY_TEMPLATE )
  190.             yy_sym = m[yy_sym];
  191. #endif
  192.         }
  193.  
  194.         yy_curst = n[b[yy_curst] + yy_sym];
  195.  
  196. #endif
  197.  
  198.         yy_st_buf[yy_c_buf_p] = yy_curst;
  199.  
  200.         }
  201. #ifdef FLEX_INTERACTIVE_SCANNER
  202.     while ( b[yy_curst] != YY_JAM_BASE );
  203. #else
  204.     while ( yy_curst != YY_JAM );
  205.     --yy_c_buf_p; /* put back character we jammed on */
  206.  
  207. #endif
  208.  
  209.     if ( yy_c_buf_p >= yy_b_buf_p )
  210.         { /* we matched some text */
  211.         yy_curst = yy_st_buf[yy_c_buf_p];
  212.         yy_lp = l[yy_curst];
  213.  
  214. #ifdef FLEX_REJECT_ENABLED
  215. find_rule: /* we branch to this label when doing a REJECT */
  216. #endif
  217.  
  218.         for ( ; ; ) /* until we find what rule we matched */
  219.         {
  220. #ifdef FLEX_REJECT_ENABLED
  221.         if ( yy_lp && yy_lp < l[yy_curst + 1] )
  222.             {
  223.             yy_act = a[yy_lp];
  224.             goto do_action; /* "continue 2" */
  225.             }
  226. #else
  227.         if ( yy_lp )
  228.             {
  229.             yy_act = yy_lp;
  230.             goto do_action; /* "continue 2" */
  231.             }
  232. #endif
  233.  
  234.         if ( --yy_c_buf_p < yy_b_buf_p )
  235.             break;
  236.  
  237.         yy_curst = yy_st_buf[yy_c_buf_p];
  238.         yy_lp = l[yy_curst];
  239.         }
  240.         }
  241.  
  242.     /* if we got this far, then we didn't find any accepting
  243.      * states
  244.      */
  245.  
  246.     /* so that the default applies to the first char read */
  247.     ++yy_c_buf_p;
  248.  
  249.     yy_act = YY_DO_DEFAULT;
  250.     }
  251.     }
  252.  
  253.     /*NOTREACHED*/
  254.     }
  255.  
  256.  
  257. static int unput( c )
  258. char c;
  259.  
  260.     {
  261.     YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */
  262.  
  263.     if ( yy_c_buf_p == 0 )
  264.     {
  265.     register int i;
  266.     register int yy_buf_pos = YY_BUF_MAX;
  267.  
  268.     for ( i = yy_e_buf_p; i >= yy_c_buf_p; --i )
  269.         {
  270.         yy_ch_buf[yy_buf_pos] = yy_ch_buf[i];
  271.         yy_st_buf[yy_buf_pos] = yy_st_buf[i];
  272.         --yy_buf_pos;
  273.         }
  274.  
  275.     yy_c_buf_p = YY_BUF_MAX - yy_e_buf_p;
  276.     yy_e_buf_p = YY_BUF_MAX;
  277.     }
  278.  
  279.     if ( yy_c_buf_p <= 0 )
  280.     YY_FATAL_ERROR( "flex scanner push-back overflow" );
  281.  
  282.     if ( yy_c_buf_p >= yy_b_buf_p && yy_ch_buf[yy_c_buf_p] == '\n' )
  283.     yy_ch_buf[yy_c_buf_p - 1] = '\n';
  284.  
  285.     yy_ch_buf[yy_c_buf_p--] = c;
  286.  
  287.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  288.     }
  289.  
  290.  
  291. static int input()
  292.  
  293.     {
  294.     int c;
  295.  
  296.     YY_DO_BEFORE_SCAN
  297.  
  298.     if ( yy_c_buf_p == yy_e_buf_p )
  299.     { /* need more input */
  300.     int yy_n_chars;
  301.  
  302.     /* we can throw away the entire current buffer */
  303.     if ( yy_saw_eof )
  304.         {
  305.         if ( yywrap() )
  306.         return ( EOF );
  307.  
  308.         YY_INIT;
  309.         }
  310.  
  311.     yy_b_buf_p = 0;
  312.     YY_INPUT( yy_ch_buf, yy_n_chars, YY_MAX_LINE );
  313.  
  314.     if ( yy_n_chars == YY_NULL )
  315.         {
  316.         yy_saw_eof = 1;
  317.  
  318.         if ( yywrap() )
  319.         return ( EOF );
  320.  
  321.         YY_INIT;
  322.  
  323.         return ( input() );
  324.         }
  325.  
  326.     yy_c_buf_p = -1;
  327.     yy_e_buf_p = yy_n_chars - 1;
  328.     }
  329.  
  330.     c = yy_ch_buf[++yy_c_buf_p];
  331.  
  332.     YY_DO_BEFORE_ACTION;
  333.  
  334.     return ( c );
  335.     }
  336. 
  337.